package com.chixing.day04_oop;

public class MethodDemo {
    // 值传递： 基本数据类型的值被复制了一份，所以内存当中有 两个独立 的值
    public static void fun1(int x){
        x = 20;
    }
    // 引用传递 指向 同一个 堆内存
    public static void fun2(Car car){
        car.setCarName("ZZZ");
        car.setCarBrand("奔驰");
    }

    public static void main(String[] args) {
        int x = 10;
        fun1(x);
        System.out.println("x = "+x);//10

        Car car= new Car(103, "CCC车辆", "特斯拉", "绿");
        fun2(car);
        System.out.println("car name: "+car.getCarName());

        int[] a={10 ,20 ,30};
        fun3(a);
        System.out.println("a[0]: "+a[0]);
    }

    private static void fun3(int[] a) {
        a[0]=99;
    }
}
